<?xml version="1.0" encoding="UTF-8"?>
<%@page contentType="text/html; charset=UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
	<title>Bookstore :: Panier</title>
	<%@include file="include.jsp" %>
</head>

<body>
	<%@include file="commun.jsp" %>
	
	<div class="contenuAvecMenu contenuAvecOutils">
		<h2>Panier</h2>
		<div class="boite bleue">
			<%if(orderCommun != null && !orderCommun.getBooks().isEmpty()) {%>
				<table>
					<tr>
						<th class="large">Titre</th>
						<th class="moyenne">Prix unitaire</th>
						<th class="etroite">Quantite</th>
						<th class="moyenne">Total</th>
					</tr>
					<% for (Entry<Book, Integer> entryCommun : orderCommun.getBooks().entrySet()) { %>
						<tr>
							<td><%=entryCommun.getKey()%></td>
							<td class="centree"><%=FormatUtil.formatPrice(entryCommun.getKey().getPrice())%></td>
							<td class="centree"><a href="ModifyQuantity.do?type=plus&id=<%=entryCommun.getKey().getId()%>"><img src="resources/images/add.png"/></a><%=entryCommun.getValue()%><a href="ModifyQuantity.do?type=moins&id=<%=entryCommun.getKey().getId()%>"><img src="resources/images/delete.png"/></a></td>
							<td class="centree"><%=FormatUtil.formatPrice(orderCommun.calculateSubTotal(entryCommun.getKey()))%></td>
						</tr>
					<% } %>
					<tr>
						<td colspan="3" style="text-align:right;"><strong>Total commande</strong></td>
						<td class="centree"><%=FormatUtil.formatPrice(orderCommun.calculateTotal())%></td>
					</tr>
				</table>
				<%if (userCommun != null) { %>
				<form method="post" action="SaveOrder.do">
					<input type="submit" value="Commander" />
				</form>
				<%} else { %>
					<h4>Merci de vous connecter pour valider la commande !</h4>
			<%		}
			  } else { %>
				<h4>Votre panier est vide !</h4>
			<%} %>
		</div>
	</div>
</body>
	
	
</html>